$(function () {
    let count
    let num = 0

    $.ajax({
        method: 'get',
        async: true,
        url: 'http://chst.vip:1234/api/getbrandtitle',
        success: function (res) {
            let kong = ``
            let kongArr = []
            res.result.forEach(element => {
                kong += ` <li brandTitleId=${element.brandTitleId}>
                            <p class="showp">${element.brandTitle}
                                <span class="sjx">
                                </span>
                            </p>
                        </li>`
            });
            $('main .show').html(kong)

            ;[...$('main .show li')].forEach(item=>{
                fetch(`http://chst.vip:1234/api/getbrand?brandtitleid=${$(item).attr('brandTitleId')}`).then(response=>{
                    return response.json()
                }).then(val=>{
                    let kongli = `<ul class="showin">`
                    val.result.forEach((item1, index2) => {
                        
                        kongli += `<li brandtitleid=${index2}>
                                    <i>${index2}</i>
                                    <span>${item1.brandName}</span>
                                    <p>${item1.brandInfo}</p>
                                </li>`

                    })
                    kongli += `</ul>`
                    $(item).children('p').after(kongli)
                    $(item).children('.showin').slideUp(0)
                    $(item).children('p').click(function(){
                        $(item).children('.showin').slideToggle(300 ).siblings().children('.show').slideUp(0)
                    })

                    $(item).children('.showin').children('li').click(function(){
                       location.href=`http://127.0.0.1:5500/domo/千锋商城项目/html/particular.html?categoryId=0`
                    })
                })
            })
        
        }
    })





    toTop1()


    
    
})


